package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.T05;
import com.ruoyi.service.IT05Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公司部门Controller
 * 
 * @author ruoyi
 * @date 2024-07-26
 */
@RestController
@RequestMapping("/system/t05")
public class T05Controller extends BaseController
{
    @Autowired
    private IT05Service t05Service;

    /**
     * 查询公司部门列表
     */
    @PreAuthorize("@ss.hasPermi('system:t05:list')")
    @GetMapping("/getDepartmentList")
    @ApiOperation("部门列表")
    public TableDataInfo getDepartmentList()
    {
        startPage();
        List<T05> list = t05Service.selectT05List();
        System.out.println("部门列表如下："+list);
        return getDataTable(list);
    }

    /**
     * 导出公司部门列表
     */
    @PreAuthorize("@ss.hasPermi('system:t05:export')")
    @ApiOperation("列表")
    @Log(title = "公司部门", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response)
    {
        List<T05> list = t05Service.selectT05List();
        ExcelUtil<T05> util = new ExcelUtil<T05>(T05.class);
        util.exportExcel(response, list, "公司部门数据");
    }

    /**
     * 获取公司部门详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:t05:query')")
    @GetMapping(value = "/{F0501}")
    public AjaxResult getInfo(@PathVariable("F0501") Long F0501)
    {
        return success(t05Service.selectT05ByF0501(F0501));
    }

    /**
     * 新增公司部门
     */
    @PreAuthorize("@ss.hasPermi('system:t05:add')")
    @Log(title = "公司部门", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody T05 t05)
    {
        return toAjax(t05Service.insertT05(t05));
    }

    /**
     * 修改公司部门
     */
    @PreAuthorize("@ss.hasPermi('system:t05:edit')")
    @Log(title = "公司部门", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody T05 t05)
    {
        return toAjax(t05Service.updateT05(t05));
    }

    /**
     * 删除公司部门
     */
    @PreAuthorize("@ss.hasPermi('system:t05:remove')")
    @Log(title = "公司部门", businessType = BusinessType.DELETE)
	@DeleteMapping("/{F0501s}")
    public AjaxResult remove(@PathVariable Long[] F0501s)
    {
        return toAjax(t05Service.deleteT05ByF0501s(F0501s));
    }
}
